#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include "string.h"
#include "medecin.h"
#include "infirmier.h"
#include "patient.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

void
on_databaseaccueil_clicked                    (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *window2;
	GtkWidget *windowaccueil;
	windowaccueil = lookup_widget(objet_graphique,"windowaccueil");
	gtk_widget_hide(windowaccueil);
	window2 = create_window2();
	gtk_widget_show(window2);
}


void
on_eventsaccueil_clicked                    (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *windowevents;
	GtkWidget *windowaccueil;
	windowaccueil = lookup_widget(objet_graphique,"windowaccueil");
	gtk_widget_hide(windowaccueil);
	windowevents = create_windowevents();
	gtk_widget_show(windowevents);
}

void
on_windowevents_show                    (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *selectionidevents;
	selectionidevents = lookup_widget(objet_graphique,"selectionidevents");
gtk_combo_box_append_text(GTK_COMBO_BOX(selectionidevents),"");
gtk_combo_box_set_active(GTK_COMBO_BOX(selectionidevents),0);
}


void
on_EXITaccueil_clicked                        (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *windowaccueil;
	windowaccueil = lookup_widget(objet_graphique,"windowaccueil");
	gtk_widget_hide(windowaccueil);
	gtk_main_quit();
}

void
on_retourevents_clicked               (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *windowevents;
	GtkWidget *windowaccueil;
	windowevents = lookup_widget(objet_graphique,"windowevents");
	gtk_widget_hide(windowevents);
	windowaccueil = create_windowaccueil();
	gtk_widget_show(windowaccueil);

}

void
on_analyseevents_clicked              (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
  	GtkWidget *time1;
  	GtkWidget *time2;
  	GtkWidget *time3;
  	GtkWidget *time4;
  	GtkWidget *time5;
  	GtkWidget *time6;
  	GtkWidget *time7;
  	GtkWidget *time8;
  	GtkWidget *time9;
  	GtkWidget *time10;
  	GtkWidget *time11;
  	GtkWidget *time12;
  	GtkWidget *time13;
  	GtkWidget *time14;
	GtkWidget *selectionidevents;
	selectionidevents = lookup_widget(objet_graphique,"selectionidevents");
	time1 = lookup_widget (objet_graphique,"time1");
	time2 = lookup_widget (objet_graphique,"time2");
	time3 = lookup_widget (objet_graphique,"time3");
	time4 = lookup_widget (objet_graphique,"time4");
	time5 = lookup_widget (objet_graphique,"time5");
	time6 = lookup_widget (objet_graphique,"time6");
	time7 = lookup_widget (objet_graphique,"time7");
	time8 = lookup_widget (objet_graphique,"time8");
	time9 = lookup_widget (objet_graphique,"time9");
	time10 = lookup_widget (objet_graphique,"time10");
	time11 = lookup_widget (objet_graphique,"time11");
	time12 = lookup_widget (objet_graphique,"time12");
	time13 = lookup_widget (objet_graphique,"time13");
	time14 = lookup_widget (objet_graphique,"time14");	
	 
int i,np,nc;
Events *str;
char parcours[CAP_MAX][CHAR_MAX];
char ID[20];
definitionparcours("parcours.txt",parcours,&nc);
str=analyse_events("evenements.log",parcours,&np);

for(i=0;i<20;i++)
{
gtk_combo_box_remove_text(GTK_COMBO_BOX(selectionidevents),0);
}
for(i=0;i<np;i++)
{
sprintf(ID,"%ld",str[i].ID);
gtk_combo_box_append_text(GTK_COMBO_BOX(selectionidevents),ID);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(selectionidevents),0);
	
}

void
on_definitionparcoursevents_clicked  (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *windowdefinitionparcoursevents;
	GtkWidget *windowevents;
	GtkWidget *affichagedefinitionparcoursevents;
	windowevents = lookup_widget(objet_graphique,"windowevents");
	gtk_widget_hide(windowevents);
	windowdefinitionparcoursevents = create_windowdefinitionparcoursevents();
	gtk_widget_show(windowdefinitionparcoursevents);
	affichagedefinitionparcoursevents = lookup_widget(GTK_WIDGET(windowdefinitionparcoursevents),"affichagedefinitionparcoursevents");
	char label[1000]="";
	char capteurs[300]="";
	char buf[20]="N° ";
	char fichierparcours[CHAR_MAX]="parcours.txt";
	char parcours[CAP_MAX][CHAR_MAX];
	int i,nc;
	definitionparcours(fichierparcours,parcours,&nc);
	for(i=0;i<nc;i++)
			{
			sprintf(capteurs,"%s%d  : %s",buf,i+1,parcours[i]);
			strcat(label,capteurs);
			strcat(label,"\n");
			}	
	gtk_label_set_text(GTK_LABEL(affichagedefinitionparcoursevents),label);
}
	
void
on_gestionparcoursevents_clicked     (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{

}

void
on_visualiserevents_clicked           (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
  GtkWidget *selectionidevents;
  GtkWidget *capteur1yesevents;
  GtkWidget *capteur1noevents;
  GtkWidget *capteur2yesevents;
  GtkWidget *capteur2noevents;
  GtkWidget *capteur3yesevents;
  GtkWidget *capteur3noevents;
  GtkWidget *capteur4yesevents;
  GtkWidget *capteur4noevents;
  GtkWidget *capteur5yesevents;
  GtkWidget *capteur5noevents;
  GtkWidget *capteur6yesevents;
  GtkWidget *capteur6noevents;
  GtkWidget *capteur7yesevents;
  GtkWidget *capteur7noevents;
  GtkWidget *capteur8yesevents;
  GtkWidget *capteur8noevents;
  GtkWidget *capteur9yesevents;
  GtkWidget *capteur9noevents;
  GtkWidget *capteur10yesevents;
  GtkWidget *capteur10noevents;
  GtkWidget *capteur11yesevents;
  GtkWidget *capteur11noevents;
  GtkWidget *capteur12yesevents;
  GtkWidget *capteur12noevents;
  GtkWidget *capteur13yesevents;
  GtkWidget *capteur14yesevents;
  GtkWidget *alerte;
  
  GtkWidget *time1;
  GtkWidget *time2;
  GtkWidget *time3;
  GtkWidget *time4;
  GtkWidget *time5;
  GtkWidget *time6;
  GtkWidget *time7;
  GtkWidget *time8;
  GtkWidget *time9;
  GtkWidget *time10;
  GtkWidget *time11;
  GtkWidget *time12;
  GtkWidget *time13;
  GtkWidget *time14;

  selectionidevents = lookup_widget(objet_graphique,"selectionidevents");
  capteur1yesevents = lookup_widget(objet_graphique,"capteur1yesevents");
  capteur2yesevents = lookup_widget(objet_graphique,"capteur2yesevents");
  capteur3yesevents = lookup_widget(objet_graphique,"capteur3yesevents");
  capteur4yesevents = lookup_widget(objet_graphique,"capteur4yesevents");
  capteur5yesevents = lookup_widget(objet_graphique,"capteur5yesevents");
  capteur6yesevents = lookup_widget(objet_graphique,"capteur6yesevents");
  capteur7yesevents = lookup_widget(objet_graphique,"capteur7yesevents");
  capteur8yesevents = lookup_widget(objet_graphique,"capteur8yesevents");
  capteur9yesevents = lookup_widget(objet_graphique,"capteur9yesevents");
  capteur10yesevents = lookup_widget(objet_graphique,"capteur10yesevents");
  capteur11yesevents = lookup_widget(objet_graphique,"capteur11yesevents");
  capteur12yesevents = lookup_widget(objet_graphique,"capteur12yesevents");
  capteur13yesevents = lookup_widget(objet_graphique,"capteur13yesevents");
  capteur14yesevents = lookup_widget(objet_graphique,"capteur14yesevents");
  capteur1noevents = lookup_widget(objet_graphique,"capteur1noevents");
  capteur2noevents = lookup_widget(objet_graphique,"capteur2noevents");
  capteur3noevents = lookup_widget(objet_graphique,"capteur3noevents");
  capteur4noevents = lookup_widget(objet_graphique,"capteur4noevents");
  capteur5noevents = lookup_widget(objet_graphique,"capteur5noevents");
  capteur6noevents = lookup_widget(objet_graphique,"capteur6noevents");
  capteur7noevents = lookup_widget(objet_graphique,"capteur7noevents");
  capteur8noevents = lookup_widget(objet_graphique,"capteur8noevents");
  capteur9noevents = lookup_widget(objet_graphique,"capteur9noevents");
  capteur10noevents = lookup_widget(objet_graphique,"capteur10noevents");
  capteur11noevents = lookup_widget(objet_graphique,"capteur11noevents");
  capteur12noevents = lookup_widget(objet_graphique,"capteur12noevents");
  alerte = lookup_widget(objet_graphique,"alerte");
  time1 = lookup_widget (objet_graphique,"time1");
  time2 = lookup_widget (objet_graphique,"time2");
  time3 = lookup_widget (objet_graphique,"time3");
  time4 = lookup_widget (objet_graphique,"time4");
  time5 = lookup_widget (objet_graphique,"time5");
  time6 = lookup_widget (objet_graphique,"time6");
  time7 = lookup_widget (objet_graphique,"time7");
  time8 = lookup_widget (objet_graphique,"time8");
  time9 = lookup_widget (objet_graphique,"time9");
  time10 = lookup_widget (objet_graphique,"time10");
  time11 = lookup_widget (objet_graphique,"time11");
  time12 = lookup_widget (objet_graphique,"time12"); 
  time13 = lookup_widget (objet_graphique,"time13");
  time14 = lookup_widget (objet_graphique,"time14"); 
  
gtk_widget_hide (capteur1noevents);
gtk_widget_hide (capteur1yesevents); 
gtk_widget_hide (capteur2noevents);
gtk_widget_hide (capteur2yesevents); 
gtk_widget_hide (capteur3noevents);
gtk_widget_hide (capteur3yesevents); 
gtk_widget_hide (capteur4noevents);
gtk_widget_hide (capteur4yesevents); 
gtk_widget_hide (capteur5noevents);
gtk_widget_hide (capteur5yesevents); 
gtk_widget_hide (capteur6noevents);
gtk_widget_hide (capteur6yesevents); 
gtk_widget_hide (capteur7noevents);
gtk_widget_hide (capteur7yesevents); 
gtk_widget_hide (capteur8noevents);
gtk_widget_hide (capteur8yesevents); 
gtk_widget_hide (capteur9noevents);
gtk_widget_hide (capteur9yesevents); 
gtk_widget_hide (capteur10noevents);
gtk_widget_hide (capteur10yesevents); 
gtk_widget_hide (capteur11noevents);
gtk_widget_hide (capteur11yesevents); 
gtk_widget_hide (capteur12noevents);
gtk_widget_hide (capteur12yesevents); 
gtk_widget_hide (capteur13yesevents);
gtk_widget_hide (capteur14yesevents); 
gtk_widget_hide (alerte);
gtk_widget_hide (time1);
gtk_widget_hide (time2);
gtk_widget_hide (time3);
gtk_widget_hide (time4);
gtk_widget_hide (time5);
gtk_widget_hide (time6);
gtk_widget_hide (time7);
gtk_widget_hide (time8);
gtk_widget_hide (time9);
gtk_widget_hide (time10);
gtk_widget_hide (time11);
gtk_widget_hide (time12);
gtk_widget_hide (time13);
gtk_widget_hide (time14);

int i=0,a=0,np,nc;
Events *str;
char parcours[100][100];
char ID[200],times[20000]="";
definitionparcours("parcours.txt",parcours,&nc);
str=analyse_events("evenements.log",parcours,&np);
strcpy(ID,gtk_combo_box_get_active_text(GTK_COMBO_BOX(selectionidevents)));

while((atoi(ID)!=str[i].ID && i<=20))
{
i++;
}
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[0]);
	gtk_label_set_text(GTK_LABEL(time1),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[1]);
	gtk_label_set_text(GTK_LABEL(time2),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[2]);
	gtk_label_set_text(GTK_LABEL(time3),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[3]);
	gtk_label_set_text(GTK_LABEL(time4),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[4]);
	gtk_label_set_text(GTK_LABEL(time5),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[5]);
	gtk_label_set_text(GTK_LABEL(time6),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[6]);
	gtk_label_set_text(GTK_LABEL(time7),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[7]);
	gtk_label_set_text(GTK_LABEL(time8),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[8]);
	gtk_label_set_text(GTK_LABEL(time9),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[9]);
	gtk_label_set_text(GTK_LABEL(time10),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[10]);
	gtk_label_set_text(GTK_LABEL(time11),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[11]);
	gtk_label_set_text(GTK_LABEL(time12),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[12]);
	gtk_label_set_text(GTK_LABEL(time13),times);
	strcpy(times,"");
	sprintf(times,"%s",str[i].time[13]);
	gtk_label_set_text(GTK_LABEL(time14),times);

switch (str[i].capteur[0])
{
case 0 : 
gtk_widget_show (capteur1noevents);a=1;
break;
case 1 :
gtk_widget_show (capteur1yesevents); 
gtk_widget_show (time1);
break;
}

switch (str[i].capteur[1])
{
case 0 : 
gtk_widget_show (capteur2noevents);a=1;
break;
case 1 :
gtk_widget_show (capteur2yesevents);
gtk_widget_show (time2);
break;
}

switch (str[i].capteur[2])
{
case 0 : 
gtk_widget_show (capteur3noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur3yesevents);
gtk_widget_show (time3);
break;
}

switch (str[i].capteur[3])
{
case 0 : 
gtk_widget_show (capteur4noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur4yesevents);
gtk_widget_show (time4);
break;
}

switch (str[i].capteur[4])
{
case 0 : 
gtk_widget_show (capteur5noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur5yesevents);
gtk_widget_show (time5);
break;
}

switch (str[i].capteur[5])
{
case 0 : 
gtk_widget_show (capteur6noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur6yesevents);
gtk_widget_show (time6);
break;
}

switch (str[i].capteur[6])
{
case 0 : 
gtk_widget_show (capteur7noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur7yesevents);
gtk_widget_show (time7);
break;
}

switch (str[i].capteur[7])
{
case 0 : 
gtk_widget_show (capteur8noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur8yesevents); 
gtk_widget_show (time8);
break;
}

switch (str[i].capteur[8])
{
case 0 : 
gtk_widget_show (capteur9noevents); 
break;
case 1 :
gtk_widget_show (capteur9yesevents);
gtk_widget_show (time9);
break;
}

switch (str[i].capteur[9])
{
case 0 : 
gtk_widget_show (capteur10noevents); 
break;
case 1 :
gtk_widget_show (capteur10yesevents);
gtk_widget_show (time10);
break;
}

switch (str[i].capteur[10])
{
case 0 : 
gtk_widget_show (capteur11noevents); 
break;
case 1 :
gtk_widget_show (capteur11yesevents);
gtk_widget_show (time11);
break;
}

switch (str[i].capteur[11])
{
case 0 : 
gtk_widget_show (capteur12noevents);a=1; 
break;
case 1 :
gtk_widget_show (capteur12yesevents);
gtk_widget_show (time12);
break;
}

switch (str[i].capteur[12])
{
case 1 :
gtk_widget_show (capteur13yesevents);a=1; 
gtk_widget_show (time13);
break;
}

switch (str[i].capteur[13])
{
case 1 :
gtk_widget_show (capteur14yesevents);a=1; 
gtk_widget_show (time14);
break;
}

if (a==1)
{
gtk_widget_show(alerte);
}


}

void
on_contactsecuriteevents_clicked     (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{

}

void
on_alarmeevents_clicked               (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{

}

void
on_detailsidevents_clicked           (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{

}

void
on_retourdefinitionparcoursevents_clicked               (GtkWidget       *objet_graphique,
                                        gpointer         user_data)
{
	GtkWidget *windowdefinitionparcoursevents;
	GtkWidget *windowevents;
	windowdefinitionparcoursevents = lookup_widget(objet_graphique,"windowdefinitionparcoursevents");
	gtk_widget_hide(windowdefinitionparcoursevents);
	windowevents = create_windowevents();
	gtk_widget_show(windowevents);
}

void on_button1_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
//condition
		GtkWidget *windowaccueil;
                GtkWidget *window1;
                window1 = lookup_widget(objet_graphique,"window1");
                gtk_widget_hide(window1);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button2_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window3;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button3_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window5;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button4_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window4;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button5_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}

/* boutton afficher*/
void on_button11_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window23;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window23 = create_window23();
		gtk_widget_show(window23);

	Medecin M;
	char chemin []="medecin.txt";
	GtkWidget *label113;
	label113= lookup_widget(GTK_WIDGET(window23),"label113");
	char temp[10000]="";
	char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
FILE*f;
f=fopen(chemin,"rb");
if(f!=NULL)
{
strcpy (M.nom," " ) ;
strcpy(M.prenom," ");
M.age=0;
M.cin=0;
strcpy(M.role," ");
M.ID=0;
strcpy(M.sexe," ");
M.date_embauche.jour=0;
M.date_embauche.mois=0;
M.date_embauche.annee=0;
M.date_naissance.jour=0;
M.date_naissance.mois=0;
M.date_naissance.annee=0;


   fread(&M,sizeof(Medecin),1,f);
   do
  {
   sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %ld  %s %d  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
 strcat(temp,buf);
strcat(temp,"\n");
 }
   while(((fread(&M,sizeof(Medecin),1,f))!=0)&&(feof(f)!=1));
}

fclose(f);

gtk_label_set_text(GTK_LABEL(label113),temp);
}

//initialisation
void on_button12_clicked(GtkWidget *objet_graphique,gpointer user_data)
{


                GtkWidget *window29;
                GtkWidget *window3;
GtkWidget *label123;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window29 = create_window29();
		gtk_widget_show(window29);





char fichier_medecin[]="medecin.txt";

char tmp[50];
FILE *f;
f=fopen(fichier_medecin,"wb");
fclose(f);

label123= lookup_widget(GTK_WIDGET(window29),"label123");
strcat(tmp,"le fichier medecin est initialiser");
 gtk_label_set_text(GTK_LABEL(label123),tmp);



}


void on_button8_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window17;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window17 = create_window17();
		gtk_widget_show(window17);
}


void on_button10_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window26;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window26 = create_window26();
		gtk_widget_show(window26);



}

//affichage de l'archive
void on_button9_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window20;//declaration
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window3);//fermer
                window20 = create_window20();//cree
		gtk_widget_show(window20);//afficher

        char archive_medecin[]="archive_medecin.txt";
        Medecin M;
        GtkWidget *label110;//declaration
	label110= lookup_widget(GTK_WIDGET(window20),"label110");//
        char temp[10000]="";
        char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
FILE *a;
a=fopen(archive_medecin,"rb");
if(a!=NULL)
{
while(fread(&M,sizeof(Medecin),1,a)!=0)
{
   sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %ld  %s %d  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
strcat(temp,buf);
strcat(temp,"\n");
}
}

fclose(a);

gtk_label_set_text(GTK_LABEL(label110),temp);//ecrire le tmp dans le label

}


void on_button7_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window9;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window9 = create_window9();
		gtk_widget_show(window9);
}


void on_button6_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window6;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window6 = create_window6();
		gtk_widget_show(window6);
}


void on_button14_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window8;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window8 = create_window8();
		gtk_widget_show(window8);
}


void on_button15_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window11;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window11 = create_window11();
		gtk_widget_show(window11);
}


void on_button16_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window19;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window19 = create_window19();
		gtk_widget_show(window19);
}


void on_button17_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window21;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window21 = create_window21();
		gtk_widget_show(window21);
	 char archive_patient[]="archive_patient.txt";
        Patient M;
        GtkWidget *label111;//declaration
	label111= lookup_widget(GTK_WIDGET(window21),"label111");//
        char temp[10000]="";
        char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Admission: ";
FILE *a;
a=fopen(archive_patient,"rb");
if(a!=NULL)
{
while(fread(&M,sizeof(Patient),1,a)!=0)
{
   sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %ld  %s %d  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
strcat(temp,buf);
strcat(temp,"\n");
}
}
else
{strcat(temp,"erreur dans l'ouvertur de l'archive");}
fclose(a);
gtk_label_set_text(GTK_LABEL(label111),temp);//ecrire le tmp dans le label
}


void on_button18_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window28;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window28 = create_window28();
		gtk_widget_show(window28);
}


void on_button19_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window24;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window24 = create_window24();
		gtk_widget_show(window24);
	Patient M;
	char chemin []="patient.txt";
	GtkWidget *label114;
	label114= lookup_widget(GTK_WIDGET(window24),"label114");
	char temp[10000]="";
	char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
FILE*f;
f=fopen(chemin,"rb");
if(f!=NULL)
{
strcpy (M.nom," " ) ;
strcpy(M.prenom," ");
M.age=0;
M.cin=0;
strcpy(M.role," ");
M.ID=0;
strcpy(M.sexe," ");
M.date_embauche.jour=0;
M.date_embauche.mois=0;
M.date_embauche.annee=0;
M.date_naissance.jour=0;
M.date_naissance.mois=0;
M.date_naissance.annee=0;


   fread(&M,sizeof(Patient),1,f);
   do
  {
   sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %ld  %s %d  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
 strcat(temp,buf);
strcat(temp,"\n");
 }
   while(((fread(&M,sizeof(Patient),1,f))!=0)&&(feof(f)!=1));
}

fclose(f);

gtk_label_set_text(GTK_LABEL(label114),temp);

}


void on_button20_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
char fichier_Patient[]="patient.txt";

FILE *f;
f=fopen(fichier_Patient,"wb");
fclose(f);
}


void on_button21_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window7;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window7 = create_window7();
		gtk_widget_show(window7);
}


void on_button22_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window10;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window10 = create_window10();
		gtk_widget_show(window10);
}


void on_button23_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window18;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window18 = create_window18();
		gtk_widget_show(window18);
}

//affichage de l'archive
void on_button24_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window22;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window22 = create_window22();
		gtk_widget_show(window22);

        char archive_infirmier[]="archive_infirmier.txt";
        infirmier M;
        GtkWidget *label112;//declaration
	label112= lookup_widget(GTK_WIDGET(window22),"label112");//
        char temp[10000]="";
        char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
FILE *a;
a=fopen(archive_infirmier,"rb");
if(a!=NULL)
{
while(fread(&M,sizeof(infirmier),1,a)!=0)
{
   sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %ld  %s %d  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
strcat(temp,buf);
strcat(temp,"\n");
}
}
fclose(a);
gtk_label_set_text(GTK_LABEL(label112),temp);//ecrire le tmp dans le label
}


void on_button25_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window27;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window27 = create_window27();
		gtk_widget_show(window27);
}


void on_button26_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window24;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window24 = create_window24();
		gtk_widget_show(window24);

	infirmier M;
	char chemin []="infirmier.txt";
	GtkWidget *label114;
	label114= lookup_widget(GTK_WIDGET(window24),"label114");
	char temp[10000]="";
	char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
FILE*f;
f=fopen(chemin,"rb");
if(f!=NULL)
{
strcpy (M.nom," " ) ;
strcpy(M.prenom," ");
M.age=0;
M.cin=0;
strcpy(M.role," ");
M.ID=0;
strcpy(M.sexe," ");
M.date_embauche.jour=0;
M.date_embauche.mois=0;
M.date_embauche.annee=0;
M.date_naissance.jour=0;
M.date_naissance.mois=0;
M.date_naissance.annee=0;


   fread(&M,sizeof(infirmier),1,f);
   do
  {
   sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %ld  %s %d  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
 strcat(temp,buf);
strcat(temp,"\n");
 }
   while(((fread(&M,sizeof(infirmier),1,f))!=0)&&(feof(f)!=1));
}

fclose(f);

gtk_label_set_text(GTK_LABEL(label114),temp);


}


void on_button27_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

char fichier_infirmier[]="infirmier.txt";

FILE *f;
f=fopen(fichier_infirmier,"wb");
fclose(f);

}

/* boutton pour enregister le medecin*/
void on_button28_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

	Medecin M;
	char chemin[]="medecin.txt";
	char temp[10000]="erreur de saisie medecin:\n";
	char ma[10]="masculin";
	char fe[10]="feminin";
	int n=0;
	GtkWidget *entry3;
	GtkWidget *entry4;
	GtkWidget *entry5;
	GtkWidget *entry6;
	GtkWidget *entry7;
	GtkWidget *entry8;
	GtkWidget *entry9;
	GtkWidget *entry10;
	GtkWidget *entry11;
	GtkWidget *entry12;
	GtkWidget *entry13;
	GtkWidget *entry14;
	GtkWidget *entry15;

	entry3= lookup_widget(objet_graphique,"entry3");
	entry4= lookup_widget(objet_graphique,"entry4");
	entry5= lookup_widget(objet_graphique,"entry5");
	entry6= lookup_widget(objet_graphique,"entry6");
	entry7= lookup_widget(objet_graphique,"entry7");
	entry8= lookup_widget(objet_graphique,"entry8");
	entry9= lookup_widget(objet_graphique,"entry9");
	entry10= lookup_widget(objet_graphique,"entry10");
	entry11= lookup_widget(objet_graphique,"entry11");
	entry12= lookup_widget(objet_graphique,"entry12");
	entry13= lookup_widget(objet_graphique,"entry13");
	entry14= lookup_widget(objet_graphique,"entry14");
	entry15= lookup_widget(objet_graphique,"entry15");

	strcpy(M.nom,gtk_entry_get_text(GTK_ENTRY(entry3)));
	strcpy(M.prenom,gtk_entry_get_text(GTK_ENTRY(entry4)));
	strcpy(M.sexe,gtk_entry_get_text(GTK_ENTRY(entry5)));
	strcpy(M.role,gtk_entry_get_text(GTK_ENTRY(entry6)));
	M.cin= atoi( gtk_entry_get_text(GTK_ENTRY(entry7)));
	M.age= atoi( gtk_entry_get_text(GTK_ENTRY(entry8)));
	M.ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry9)));
	M.date_embauche.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry10)));
	M.date_embauche.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry11)));
	M.date_embauche.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry12)));
	M.date_naissance.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry13)));
	M.date_naissance.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry14)));
	M.date_naissance.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry15)));

if( ((strlen(M.nom))<3) || ((strlen(M.prenom))<3) || (((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0)) ||
((M.date_embauche.jour)>31) || ((M.date_embauche.jour)<1) || ((M.date_naissance.jour)>31) || ((M.date_naissance.jour)<1) ||
((M.date_embauche.mois)>12) || ((M.date_embauche.mois)<1) || ((M.date_naissance.mois)>12) || ((M.date_naissance.mois)<1) ||
((M.date_embauche.annee)>2014)||(M.date_naissance.annee)>(M.date_embauche.annee+20))
{
		if (((strlen(M.nom))<3))
		{
	 strcat(temp,"erreur nom \n");
		}
if (((strlen(M.prenom))<3))
		{
	 strcat(temp,"erreur prenom \n");
		}
if (((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0))
		{
	 strcat(temp,"erreur sex : masculin/feminin \n");
		}
if (((M.date_embauche.jour)>31) || ((M.date_embauche.jour)<1))
		{
	 strcat(temp,"erreur jour d'embeauche \n");
		}
if (((M.date_naissance.jour)>31) || ((M.date_naissance.jour)<1) )
		{
	 strcat(temp,"erreur jour de naissance \n");
		}
if (((M.date_embauche.mois)>12) || ((M.date_embauche.mois)<1))
		{
	 strcat(temp,"erreur mois d'embeauche \n");
		}
if (((M.date_naissance.mois)>12) || ((M.date_naissance.mois)<1))
		{
 strcat(temp,"erreur mois d'naissance \n");
		}
if ((M.date_embauche.annee)>2014)
		{
	 strcat(temp,"erreur annee d'embeauche \n");
		}
if ((M.date_naissance.annee)>(M.date_embauche.annee+20))
		{
	 strcat(temp,"erreur annee d'naissance \n");
		}
		GtkWidget *window6;//declaration
                GtkWidget *window30;
                window6 = lookup_widget(objet_graphique,"window6");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window6);//fermer
                window30 = create_window30();//cree
		gtk_widget_show(window30);//afficher
                GtkWidget *label124;
		label124= lookup_widget(GTK_WIDGET(window30),"label124");
		gtk_label_set_text(GTK_LABEL(label124),temp);
}
else{

	enregistrer_medecin(chemin,&M,&n);
	GtkWidget *window7;//declaration
                GtkWidget *window3;
                window7 = lookup_widget(objet_graphique,"window7");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window7);//fermer
                window3 = create_window3();//cree
		gtk_widget_show(window3);//afficher
}
}


void on_button29_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button30_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button31_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
	int ex;
	long int ID;
	Medecin M;
	char temp[50];
	char fichier_medecin[]="medecin.txt";
                GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	ex=existence_medecin_ID(fichier_medecin,M,ID);
	if(ex!=1)
	{
	strcpy(temp,"ID n'existe pas");
	GtkWidget *label154;
	label154= lookup_widget(GTK_WIDGET(window9),"label154");
	 gtk_label_set_text(GTK_LABEL(label154),temp);
		
	}
	else 
{
	strcpy(temp,"ID existe");
	GtkWidget *label154;
	label154= lookup_widget(GTK_WIDGET(window9),"label154");
	 gtk_label_set_text(GTK_LABEL(label154),temp);
}
	
}


void on_button32_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button33_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button34_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
	int ex;
	long int ID;
	Medecin M;
	char fichier_medecin[]="medecin.txt";
	char nom[30];
 	char tmp_medecin[]="tmp_medecin.txt";        
        GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	GtkWidget *entry157;
	entry157= lookup_widget(objet_graphique,"entry157");
	ex=existence_medecin_ID(fichier_medecin,M,ID);
	strcpy(nom,gtk_entry_get_text(GTK_ENTRY(entry157)));
	if(ex==1)
	{
	if(((strlen(nom))<3))
	{
	char temp[]="erreur nom ";
	GtkWidget *label155;
	label155= lookup_widget(GTK_WIDGET(window9),"label155");
	 gtk_label_set_text(GTK_LABEL(label155),temp);
		
	}
	else
	{
	char temp[]="nom modifier ";
	GtkWidget *label155;
	label155= lookup_widget(GTK_WIDGET(window9),"label155");
	 gtk_label_set_text(GTK_LABEL(label155),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_medecin,"rb") ;
    t=fopen(tmp_medecin,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Medecin),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.nom,nom);
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_medecin,"wb") ;
     t=fopen(tmp_medecin,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Medecin),1,t)!=0)
     {fwrite(&M,sizeof(Medecin),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_medecin,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label155;
	label155= lookup_widget(GTK_WIDGET(window9),"label155");
	 gtk_label_set_text(GTK_LABEL(label155),temp);
}
}


void on_button52_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
	
}


void on_button53_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button54_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button55_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button56_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button57_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button58_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button59_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button60_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button65_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowevents;
                GtkWidget *windowaccueil;
                windowaccueil = lookup_widget(objet_graphique,"windowaccueil");
                gtk_widget_hide(windowaccueil);
                windowevents = create_windowevents();
		gtk_widget_show(windowevents);
}


void on_Database_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window2;
                GtkWidget *windowaccueil;
                windowaccueil = lookup_widget(objet_graphique,"windowaccueil");
                gtk_widget_hide(windowaccueil);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void on_EXIT_clicked   (GtkWidget *objet_graphique,gpointer user_data)
{
	gtk_main_quit();
}


void on_visualiser_parcours_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_Home_clicked   (GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button89_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	Patient M;
	char fichier_patient[]="patient.txt";
	char nom[30];
 	char tmp_patient[]="tmp_patient.txt";        
        GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	GtkWidget *entry183;
	entry183= lookup_widget(objet_graphique,"entry183");
	ex=existence_patient_ID(fichier_patient,M,ID);
	strcpy(nom,gtk_entry_get_text(GTK_ENTRY(entry183)));
	if(ex==1)
	{
	if(((strlen(nom))<3))
	{
	char temp[]="erreur nom ";
	GtkWidget *label169;
	label169= lookup_widget(GTK_WIDGET(window11),"label169");
	 gtk_label_set_text(GTK_LABEL(label169),temp);
		
	}
	else
	{
	char temp[]="nom modifier ";
	GtkWidget *label169;
	label169= lookup_widget(GTK_WIDGET(window11),"label169");
	 gtk_label_set_text(GTK_LABEL(label169),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_patient,"rb") ;
    t=fopen(tmp_patient,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Patient),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Patient),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.nom,nom);
             fwrite(&M,sizeof(Patient),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_patient,"wb") ;
     t=fopen(tmp_patient,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Patient),1,t)!=0)
     {fwrite(&M,sizeof(Patient),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_patient,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label169;
	label169= lookup_widget(GTK_WIDGET(window11),"label169");
	 gtk_label_set_text(GTK_LABEL(label169),temp);
}
}


void on_button90_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	Patient M;
	char fichier_patient[]="patient.txt";
	char prenom[30];
 	char tmp_patient[]="tmp_patient.txt";        
        GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	GtkWidget *entry184;
	entry184= lookup_widget(objet_graphique,"entry184");
	ex=existence_patient_ID(fichier_patient,M,ID);
	strcpy(prenom,gtk_entry_get_text(GTK_ENTRY(entry184)));
	if(ex==1)
	{
	if(((strlen(prenom))<3))
	{
	char temp[]="erreur prenom ";
	GtkWidget *label170;
	label170= lookup_widget(GTK_WIDGET(window11),"label170");
	 gtk_label_set_text(GTK_LABEL(label170),temp);
		
	}
	else
	{
	char temp[]="prenom modifier ";
	GtkWidget *label170;
	label170= lookup_widget(GTK_WIDGET(window11),"label170");
	 gtk_label_set_text(GTK_LABEL(label170),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_patient,"rb") ;
    t=fopen(tmp_patient,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Patient),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Patient),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.prenom,prenom);
             fwrite(&M,sizeof(Patient),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_patient,"wb") ;
     t=fopen(tmp_patient,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Patient),1,t)!=0)
     {fwrite(&M,sizeof(Patient),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_patient,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label170;
	label170= lookup_widget(GTK_WIDGET(window11),"label170");
	 gtk_label_set_text(GTK_LABEL(label170),temp);
}
}


void on_button91_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
char ma[10]="masculin";
	char fe[10]="feminin";
	int ex;
	long int ID;
	Patient M;
	char fichier_patient[]="patient.txt";
	char sex[30];
 	char tmp_patient[]="tmp_patient.txt";        
        GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	GtkWidget *entry185;
	entry185= lookup_widget(objet_graphique,"entry185");
	ex=existence_patient_ID(fichier_patient,M,ID);
	strcpy(sex,gtk_entry_get_text(GTK_ENTRY(entry185)));
	if(ex==1)
	{
	if((((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0)))
	{
	char temp[]="erreur sex ";
	GtkWidget *label171;
	label171= lookup_widget(GTK_WIDGET(window11),"label171");
	 gtk_label_set_text(GTK_LABEL(label171),temp);
		
	}
	else
	{
	char temp[]="sex modifier ";
	GtkWidget *label171;
	label171= lookup_widget(GTK_WIDGET(window11),"label171");
	 gtk_label_set_text(GTK_LABEL(label171),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_patient,"rb") ;
    t=fopen(tmp_patient,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Patient),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Patient),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.sexe,sex);
             fwrite(&M,sizeof(Patient),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_patient,"wb") ;
     t=fopen(tmp_patient,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Patient),1,t)!=0)
     {fwrite(&M,sizeof(Patient),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_patient,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label171;
	label171= lookup_widget(GTK_WIDGET(window11),"label171");
	 gtk_label_set_text(GTK_LABEL(label171),temp);
}
}


void on_button92_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	Patient M;
	char fichier_patient[]="patient.txt";
	char role[30];
 	char tmp_patient[]="tmp_patient.txt";        
        GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	GtkWidget *entry186;
	entry186= lookup_widget(objet_graphique,"entry186");
	ex=existence_patient_ID(fichier_patient,M,ID);
	strcpy(role,gtk_entry_get_text(GTK_ENTRY(entry186)));
	if(ex==1)
	{
	
	char temp[]="role modifier ";
	GtkWidget *label172;
	label172= lookup_widget(GTK_WIDGET(window11),"label172");
	 gtk_label_set_text(GTK_LABEL(label172),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_patient,"rb") ;
    t=fopen(tmp_patient,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Patient),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Patient),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.role,role);
             fwrite(&M,sizeof(Patient),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_patient,"wb") ;
     t=fopen(tmp_patient,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Patient),1,t)!=0)
     {fwrite(&M,sizeof(Patient),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_patient,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label172;
	label172= lookup_widget(GTK_WIDGET(window11),"label172");
	 gtk_label_set_text(GTK_LABEL(label172),temp);
}
}


void on_button93_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

int ex;
	long int ID,CIN;
	Patient M;
	char fichier_patient[]="patient.txt";
 	char tmp_patient[]="tmp_patient.txt";        
        GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	GtkWidget *entry187;
	entry187= lookup_widget(objet_graphique,"entry187");
	ex=existence_patient_ID(fichier_patient,M,ID);
        CIN=atoi ( gtk_entry_get_text(GTK_ENTRY(entry187)));
	if(ex==1)
	{
	
	char temp[]="CIN modifier ";
	GtkWidget *label173;
	label173= lookup_widget(GTK_WIDGET(window11),"label173");
	 gtk_label_set_text(GTK_LABEL(label173),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_patient,"rb") ;
    t=fopen(tmp_patient,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Patient),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Patient),1,t) ;
            }
           if( ID==M.ID)
            {
		M.cin=CIN;
             fwrite(&M,sizeof(Patient),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_patient,"wb") ;
     t=fopen(tmp_patient,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Patient),1,t)!=0)
     {fwrite(&M,sizeof(Patient),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_patient,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label173;
	label173= lookup_widget(GTK_WIDGET(window11),"label173");
	 gtk_label_set_text(GTK_LABEL(label173),temp);
}
}


void on_button94_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID,age;
	Patient M;
	char fichier_patient[]="patient.txt";
 	char tmp_patient[]="tmp_patient.txt";        
        GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	GtkWidget *entry188;
	entry188= lookup_widget(objet_graphique,"entry188");
	ex=existence_patient_ID(fichier_patient,M,ID);
        age=atoi ( gtk_entry_get_text(GTK_ENTRY(entry188)));
	if(ex==1)
	{
	
	char temp[]="age modifier ";
	GtkWidget *label174;
	label174= lookup_widget(GTK_WIDGET(window11),"label174");
	 gtk_label_set_text(GTK_LABEL(label174),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_patient,"rb") ;
    t=fopen(tmp_patient,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Patient),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Patient),1,t) ;
            }
           if( ID==M.ID)
            {
		M.age=age;
             fwrite(&M,sizeof(Patient),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_patient,"wb") ;
     t=fopen(tmp_patient,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Patient),1,t)!=0)
     {fwrite(&M,sizeof(Patient),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_patient,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label174;
	label174= lookup_widget(GTK_WIDGET(window11),"label174");
	 gtk_label_set_text(GTK_LABEL(label174),temp);
}
}


void on_button95_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button96_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button97_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}

/*boutton de supression medecin*/
void on_button98_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
	int ID;
	GtkWidget *entry151;
	entry151= lookup_widget(objet_graphique,"entry151");
	ID= atoi( gtk_entry_get_text(GTK_ENTRY(entry151)));
	supprimer_medecin_ID( "medecin.txt", ID);

}


void on_button99_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
	int ID;
	GtkWidget *entry152;
	entry152= lookup_widget(objet_graphique,"entry152");
	ID= atoi( gtk_entry_get_text(GTK_ENTRY(entry152)));
	supprimer_infirmier_ID( "infirmier.txt", ID);
}


void on_button100_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
	int ID;
	GtkWidget *entry153;
	entry153= lookup_widget(objet_graphique,"entry153");
	ID= atoi( gtk_entry_get_text(GTK_ENTRY(entry153)));
	supprimer_patient_ID( "patient.txt", ID);
}


void on_button101_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window20;
                window20 = lookup_widget(objet_graphique,"window20");
                gtk_widget_hide(window20);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button102_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window21;
                window21 = lookup_widget(objet_graphique,"window21");
                gtk_widget_hide(window21);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button103_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window22;
                window22 = lookup_widget(objet_graphique,"window22");
                gtk_widget_hide(window22);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button104_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window3;
                GtkWidget *window23;
                window23 = lookup_widget(objet_graphique,"window23");
                gtk_widget_hide(window23);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button105_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window2;
                GtkWidget *window24;
                window24 = lookup_widget(objet_graphique,"window24");
                gtk_widget_hide(window24);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void on_button106_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window25;
                window25 = lookup_widget(objet_graphique,"window25");
                gtk_widget_hide(window25);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}

/* afficher medecin ID*/
void on_button107_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
	int ID,existe;
	char temp[10000]="";
	GtkWidget *window26;
	window26 = lookup_widget(objet_graphique,"window26");
	GtkWidget *entry154;
	entry154= lookup_widget(objet_graphique,"entry154");
	GtkWidget *label117;
	label117= lookup_widget(GTK_WIDGET(window26),"label117");
	ID= atoi( gtk_entry_get_text(GTK_ENTRY(entry154)));
	Medecin M;
	existe=existence_medecin_ID("medecin.txt",M,ID);
	if (existe==1)
	{FILE*f;
char fichier_medecin[]="medecin.txt";

f=fopen(fichier_medecin,"rb");
if(f!=NULL)
{
	fread(&M,sizeof(Medecin),1,f);
   do
  {
        if(ID==M.ID)
        {
        char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %d  %s %ld  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
strcat(temp,buf);
strcat(temp,"\n");

}
  }
  while(((fread(&M,sizeof(Medecin),1,f))!=0)&&(feof(f)!=1));
}
else
{
strcat(temp,"erreur lors de l'ouverture du fichier_medecin\n");
}
fclose(f);}
else {
strcat(temp,"Le medecin n'existe pas\n");
}
 gtk_label_set_text(GTK_LABEL(label117),temp);
}


void on_button110_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window3;
                GtkWidget *window26;
                window26 = lookup_widget(objet_graphique,"window26");
                gtk_widget_hide(window26);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button109_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window5;
                GtkWidget *window27;
                window27 = lookup_widget(objet_graphique,"window27");
                gtk_widget_hide(window27);
                window5 = create_window5();
		gtk_widget_show(window5);
}

/* afficher infirmier*/
void on_button108_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
	int ID,existe;
	char temp[10000]="";
	GtkWidget *window27;
	window27 = lookup_widget(objet_graphique,"window27");
	GtkWidget *entry155;
	entry155= lookup_widget(objet_graphique,"entry155");
	GtkWidget *label120;
	label120= lookup_widget(GTK_WIDGET(window27),"label120");
	ID= atoi( gtk_entry_get_text(GTK_ENTRY(entry155)));
	infirmier M;
	existe=existence_infirmier_ID("infirmier.txt",M,ID);
	if (existe==1)
	{FILE*f;
char fichier_infirmier[]="infirmier.txt";

f=fopen(fichier_infirmier,"rb");
if(f!=NULL)
{
	fread(&M,sizeof(infirmier),1,f);
   do
  {
        if(ID==M.ID)
        {
        char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %d  %s %ld  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
strcat(temp,buf);
strcat(temp,"\n");

}
  }
  while(((fread(&M,sizeof(infirmier),1,f))!=0)&&(feof(f)!=1));
}
else
{
strcat(temp,"erreur lors de l'ouverture du fichier_infirmier\n");
}
fclose(f);}
else {
strcat(temp,"Le infirmier n'existe pas\n");
}
 gtk_label_set_text(GTK_LABEL(label120),temp);
}

/*afficher patient*/
void on_button111_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
	int ID,existe;
	char temp[10000]="";
	GtkWidget *window28;
	window28 = lookup_widget(objet_graphique,"window28");
	GtkWidget *entry156;
	entry156= lookup_widget(objet_graphique,"entry156");
	GtkWidget *label122;
	label122= lookup_widget(GTK_WIDGET(window28),"label122");
	ID= atoi( gtk_entry_get_text(GTK_ENTRY(entry156)));
	Patient M;
	existe=existence_patient_ID("patient.txt",M,ID);
	if (existe==1)
	{FILE*f;
char fichier_patient[]="patient.txt";

f=fopen(fichier_patient,"rb");
if(f!=NULL)
{
	fread(&M,sizeof(Patient),1,f);
   do
  {
        if(ID==M.ID)
        {
        char buf[200]="";
	char buf0[50]="NOM: ";
	char buf1[50]="PRENOM: ";
	char buf2[50]="SEXE: ";
	char buf3[50]="ROLE: ";
	char buf4[50]="CIN: ";
	char buf5[50]="AGE: ";
	char buf6[50]="ID: ";
	char buf7[50]="Date De Naissance: ";
	char buf8[50]="Date D'Embauche: ";
sprintf(buf,"%s %s  %s %s  %s %s  %s %s  %s %d  %s %ld  %s %ld  %s %d %d %d  %s %d %d %d",buf0,M.nom,buf1,M.prenom,buf2,M.sexe,buf3,M.role,buf4,M.cin,buf5,
M.age,buf6,M.ID,buf7,M.date_naissance.jour,M.date_naissance.mois,
M.date_naissance.annee,buf8,M.date_embauche.jour,M.date_embauche.mois,M.date_embauche.annee);
strcat(temp,buf);
strcat(temp,"\n");

}
  }
  while(((fread(&M,sizeof(Patient),1,f))!=0)&&(feof(f)!=1));
}
else
{
strcat(temp,"erreur lors de l'ouverture du fichier_infirmier\n");
}
fclose(f);}
else {
strcat(temp,"Le infirmier n'existe pas\n");
}
 gtk_label_set_text(GTK_LABEL(label122),temp);
}


void on_button112_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window4;
                GtkWidget *window28;
                window28 = lookup_widget(objet_graphique,"window28");
                gtk_widget_hide(window28);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button113_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button114_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window2;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void on_button115_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window2;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void on_button116_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window2;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void on_button117_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window3;
                GtkWidget *window6;
                window6 = lookup_widget(objet_graphique,"window6");
                gtk_widget_hide(window6);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button118_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window5;
                GtkWidget *window7;
                window7 = lookup_widget(objet_graphique,"window7");
                gtk_widget_hide(window7);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button119_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window4;
                GtkWidget *window8;
                window8 = lookup_widget(objet_graphique,"window8");
                gtk_widget_hide(window8);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button120_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window3;
                GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
                gtk_widget_hide(window9);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button121_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window5;
                GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button122_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window4;
                GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
                gtk_widget_hide(window11);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button123_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window12;
                window12 = lookup_widget(objet_graphique,"window12");
                gtk_widget_hide(window12);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button124_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window13;
                window13 = lookup_widget(objet_graphique,"window13");
                gtk_widget_hide(window13);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button125_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *windowevents;
                windowevents = lookup_widget(objet_graphique,"windowevents");
                gtk_widget_hide(windowevents);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button126_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *windowaccueil;
                GtkWidget *window16;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                windowaccueil = create_windowaccueil();
		gtk_widget_show(windowaccueil);
}


void on_button127_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window3;
                GtkWidget *window17;
                window17 = lookup_widget(objet_graphique,"window17");
                gtk_widget_hide(window17);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button128_clicked          (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window5;
                GtkWidget *window18;
                window18 = lookup_widget(objet_graphique,"window18");
                gtk_widget_hide(window18);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button129_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window4;
                GtkWidget *window19;
                window19 = lookup_widget(objet_graphique,"window19");
                gtk_widget_hide(window19);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button71_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	infirmier M;
	char temp[50];
	char fichier_infirmier[]="infirmier.txt";
                GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
	if(ex!=1)
	{
	strcpy(temp,"ID n'existe pas");
	GtkWidget *label161;
	label161= lookup_widget(GTK_WIDGET(window10),"label161");
	 gtk_label_set_text(GTK_LABEL(label161),temp);
		
	}
	else 
{
	strcpy(temp,"ID existe");
	GtkWidget *label161;
	label161= lookup_widget(GTK_WIDGET(window10),"label161");
	 gtk_label_set_text(GTK_LABEL(label161),temp);
}
	
}


void on_button70_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

int ex;
	long int ID;
	Patient M;
	char temp[50];
	char fichier_patient[]="patient.txt";
                GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
	GtkWidget *entry123;

	entry123= lookup_widget(objet_graphique,"entry123");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry123)));
	ex=existence_patient_ID(fichier_patient,M,ID);
	if(ex!=1)
	{
	strcpy(temp,"ID n'existe pas");
	GtkWidget *label168;
	label168= lookup_widget(GTK_WIDGET(window11),"label168");
	 gtk_label_set_text(GTK_LABEL(label168),temp);
		
	}
	else 
{
	strcpy(temp,"ID existe");
	GtkWidget *label168;
	label168= lookup_widget(GTK_WIDGET(window11),"label168");
	 gtk_label_set_text(GTK_LABEL(label168),temp);
}
	
}


void on_button44_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	Medecin M;
	char fichier_medecin[]="medecin.txt";
	char prenom[30];
 	char tmp_medecin[]="tmp_medecin.txt";        
        GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	GtkWidget *entry158;
	entry158= lookup_widget(objet_graphique,"entry158");
	ex=existence_medecin_ID(fichier_medecin,M,ID);
	strcpy(prenom,gtk_entry_get_text(GTK_ENTRY(entry158)));
	if(ex==1)
	{
	if(((strlen(prenom))<3))
	{
	char temp[]="erreur prenom ";
	GtkWidget *label156;
	label156= lookup_widget(GTK_WIDGET(window9),"label156");
	 gtk_label_set_text(GTK_LABEL(label156),temp);
		
	}
	else
	{
	char temp[]="prenom modifier ";
	GtkWidget *label156;
	label156= lookup_widget(GTK_WIDGET(window9),"label156");
	 gtk_label_set_text(GTK_LABEL(label156),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_medecin,"rb") ;
    t=fopen(tmp_medecin,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Medecin),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.prenom,prenom);
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_medecin,"wb") ;
     t=fopen(tmp_medecin,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Medecin),1,t)!=0)
     {fwrite(&M,sizeof(Medecin),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_medecin,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label156;
	label156= lookup_widget(GTK_WIDGET(window9),"label156");
	 gtk_label_set_text(GTK_LABEL(label156),temp);
}
}


void on_button45_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
	char ma[10]="masculin";
	char fe[10]="feminin";
	int ex;
	long int ID;
	Medecin M;
	char fichier_medecin[]="medecin.txt";
	char sex[30];
 	char tmp_medecin[]="tmp_medecin.txt";        
        GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	GtkWidget *entry159;
	entry159= lookup_widget(objet_graphique,"entry159");
	ex=existence_medecin_ID(fichier_medecin,M,ID);
	strcpy(sex,gtk_entry_get_text(GTK_ENTRY(entry159)));
	if(ex==1)
	{
	if((((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0)))
	{
	char temp[]="erreur sex ";
	GtkWidget *label157;
	label157= lookup_widget(GTK_WIDGET(window9),"label157");
	 gtk_label_set_text(GTK_LABEL(label157),temp);
		
	}
	else
	{
	char temp[]="sex modifier ";
	GtkWidget *label157;
	label157= lookup_widget(GTK_WIDGET(window9),"label157");
	 gtk_label_set_text(GTK_LABEL(label157),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_medecin,"rb") ;
    t=fopen(tmp_medecin,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Medecin),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.sexe,sex);
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_medecin,"wb") ;
     t=fopen(tmp_medecin,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Medecin),1,t)!=0)
     {fwrite(&M,sizeof(Medecin),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_medecin,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label157;
	label157= lookup_widget(GTK_WIDGET(window9),"label157");
	 gtk_label_set_text(GTK_LABEL(label157),temp);
}
}


void on_button46_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	Medecin M;
	char fichier_medecin[]="medecin.txt";
	char role[30];
 	char tmp_medecin[]="tmp_medecin.txt";        
        GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	GtkWidget *entry160;
	entry160= lookup_widget(objet_graphique,"entry160");
	ex=existence_medecin_ID(fichier_medecin,M,ID);
	strcpy(role,gtk_entry_get_text(GTK_ENTRY(entry160)));
	if(ex==1)
	{
	
	char temp[]="role modifier ";
	GtkWidget *label158;
	label158= lookup_widget(GTK_WIDGET(window9),"label158");
	 gtk_label_set_text(GTK_LABEL(label158),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_medecin,"rb") ;
    t=fopen(tmp_medecin,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Medecin),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.role,role);
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_medecin,"wb") ;
     t=fopen(tmp_medecin,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Medecin),1,t)!=0)
     {fwrite(&M,sizeof(Medecin),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_medecin,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label158;
	label158= lookup_widget(GTK_WIDGET(window9),"label158");
	 gtk_label_set_text(GTK_LABEL(label158),temp);
}
}


void on_button47_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID,CIN;
	Medecin M;
	char fichier_medecin[]="medecin.txt";
 	char tmp_medecin[]="tmp_medecin.txt";        
        GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	GtkWidget *entry161;
	entry161= lookup_widget(objet_graphique,"entry161");
	ex=existence_medecin_ID(fichier_medecin,M,ID);
        CIN=atoi ( gtk_entry_get_text(GTK_ENTRY(entry161)));
	if(ex==1)
	{
	
	char temp[]="CIN modifier ";
	GtkWidget *label159;
	label159= lookup_widget(GTK_WIDGET(window9),"label159");
	 gtk_label_set_text(GTK_LABEL(label159),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_medecin,"rb") ;
    t=fopen(tmp_medecin,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Medecin),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
           if( ID==M.ID)
            {
		M.cin=CIN;
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_medecin,"wb") ;
     t=fopen(tmp_medecin,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Medecin),1,t)!=0)
     {fwrite(&M,sizeof(Medecin),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_medecin,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label159;
	label159= lookup_widget(GTK_WIDGET(window9),"label159");
	 gtk_label_set_text(GTK_LABEL(label159),temp);
}
}


void on_button48_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID,age;
	Medecin M;
	char fichier_medecin[]="medecin.txt";
 	char tmp_medecin[]="tmp_medecin.txt";        
        GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
	GtkWidget *entry43;

	entry43= lookup_widget(objet_graphique,"entry43");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry43)));
	GtkWidget *entry162;
	entry162= lookup_widget(objet_graphique,"entry162");
	ex=existence_medecin_ID(fichier_medecin,M,ID);
        age=atoi ( gtk_entry_get_text(GTK_ENTRY(entry162)));
	if(ex==1)
	{
	
	char temp[]="age modifier ";
	GtkWidget *label160;
	label160= lookup_widget(GTK_WIDGET(window9),"label160");
	 gtk_label_set_text(GTK_LABEL(label160),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_medecin,"rb") ;
    t=fopen(tmp_medecin,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(Medecin),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
           if( ID==M.ID)
            {
		M.age=age;
             fwrite(&M,sizeof(Medecin),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_medecin,"wb") ;
     t=fopen(tmp_medecin,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(Medecin),1,t)!=0)
     {fwrite(&M,sizeof(Medecin),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_medecin,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label160;
	label160= lookup_widget(GTK_WIDGET(window9),"label160");
	 gtk_label_set_text(GTK_LABEL(label160),temp);
}
}


void on_button50_clicked (GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button49_clicked (GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button51_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button72_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	infirmier M;
	char fichier_infirmier[]="infirmier.txt";
	char nom[30];
 	char tmp_infirmier[]="tmp_infirmier.txt";        
        GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	GtkWidget *entry170;
	entry170= lookup_widget(objet_graphique,"entry170");
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
	strcpy(nom,gtk_entry_get_text(GTK_ENTRY(entry170)));
	if(ex==1)
	{
	if(((strlen(nom))<3))
	{
	char temp[]="erreur nom ";
	GtkWidget *label162;
	label162= lookup_widget(GTK_WIDGET(window10),"label162");
	 gtk_label_set_text(GTK_LABEL(label162),temp);
		
	}
	else
	{
	char temp[]="nom modifier ";
	GtkWidget *label162;
	label162= lookup_widget(GTK_WIDGET(window10),"label162");
	 gtk_label_set_text(GTK_LABEL(label162),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_infirmier,"rb") ;
    t=fopen(tmp_infirmier,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(infirmier),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.nom,nom);
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_infirmier,"wb") ;
     t=fopen(tmp_infirmier,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(infirmier),1,t)!=0)
     {fwrite(&M,sizeof(infirmier),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_infirmier,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label162;
	label162= lookup_widget(GTK_WIDGET(window10),"label162");
	 gtk_label_set_text(GTK_LABEL(label162),temp);
}
}


void on_button73_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	infirmier M;
	char fichier_infirmier[]="infirmier.txt";
	char prenom[30];
 	char tmp_infirmier[]="tmp_infirmier.txt";        
        GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	GtkWidget *entry171;
	entry171= lookup_widget(objet_graphique,"entry171");
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
	strcpy(prenom,gtk_entry_get_text(GTK_ENTRY(entry171)));
	if(ex==1)
	{
	if(((strlen(prenom))<3))
	{
	char temp[]="erreur prenom ";
	GtkWidget *label163;
	label163= lookup_widget(GTK_WIDGET(window10),"label163");
	 gtk_label_set_text(GTK_LABEL(label163),temp);
		
	}
	else
	{
	char temp[]="prenom modifier ";
	GtkWidget *label163;
	label163= lookup_widget(GTK_WIDGET(window10),"label163");
	 gtk_label_set_text(GTK_LABEL(label163),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_infirmier,"rb") ;
    t=fopen(tmp_infirmier,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(infirmier),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.prenom,prenom);
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_infirmier,"wb") ;
     t=fopen(tmp_infirmier,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(infirmier),1,t)!=0)
     {fwrite(&M,sizeof(infirmier),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_infirmier,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label163;
	label163= lookup_widget(GTK_WIDGET(window10),"label163");
	 gtk_label_set_text(GTK_LABEL(label163),temp);
}
}


void on_button74_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
char ma[10]="masculin";
	char fe[10]="feminin";
	int ex;
	long int ID;
	infirmier M;
	char fichier_infirmier[]="infirmier.txt";
	char sex[30];
 	char tmp_infirmier[]="tmp_infirmier.txt";        
        GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	GtkWidget *entry172;
	entry172= lookup_widget(objet_graphique,"entry172");
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
	strcpy(sex,gtk_entry_get_text(GTK_ENTRY(entry172)));
	if(ex==1)
	{
	if((((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0)))
	{
	char temp[]="erreur sex ";
	GtkWidget *label164;
	label164= lookup_widget(GTK_WIDGET(window10),"label164");
	 gtk_label_set_text(GTK_LABEL(label164),temp);
		
	}
	else
	{
	char temp[]="sex modifier ";
	GtkWidget *label164;
	label164= lookup_widget(GTK_WIDGET(window10),"label164");
	 gtk_label_set_text(GTK_LABEL(label164),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_infirmier,"rb") ;
    t=fopen(tmp_infirmier,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(infirmier),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.sexe,sex);
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_infirmier,"wb") ;
     t=fopen(tmp_infirmier,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(infirmier),1,t)!=0)
     {fwrite(&M,sizeof(infirmier),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_infirmier,"wb+") ;
     if (t!=NULL)	
     {
     }}
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label164;
	label164= lookup_widget(GTK_WIDGET(window10),"label164");
	 gtk_label_set_text(GTK_LABEL(label164),temp);
}
}


void on_button75_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID;
	infirmier M;
	char fichier_infirmier[]="infirmier.txt";
	char role[30];
 	char tmp_infirmier[]="tmp_infirmier.txt";        
        GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	GtkWidget *entry173;
	entry173= lookup_widget(objet_graphique,"entry173");
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
	strcpy(role,gtk_entry_get_text(GTK_ENTRY(entry173)));
	if(ex==1)
	{
	
	char temp[]="role modifier ";
	GtkWidget *label165;
	label165= lookup_widget(GTK_WIDGET(window10),"label165");
	 gtk_label_set_text(GTK_LABEL(label165),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_infirmier,"rb") ;
    t=fopen(tmp_infirmier,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(infirmier),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
           if( ID==M.ID)
            {
		strcpy(M.role,role);
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_infirmier,"wb") ;
     t=fopen(tmp_infirmier,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(infirmier),1,t)!=0)
     {fwrite(&M,sizeof(infirmier),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_infirmier,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label165;
	label165= lookup_widget(GTK_WIDGET(window10),"label165");
	 gtk_label_set_text(GTK_LABEL(label165),temp);
}
}


void on_button76_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

int ex;
	long int ID,CIN;
	infirmier M;
	char fichier_infirmier[]="infirmier.txt";
 	char tmp_infirmier[]="tmp_infirmier.txt";        
        GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	GtkWidget *entry174;
	entry174= lookup_widget(objet_graphique,"entry174");
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
        CIN=atoi ( gtk_entry_get_text(GTK_ENTRY(entry174)));
	if(ex==1)
	{
	
	char temp[]="CIN modifier ";
	GtkWidget *label166;
	label166= lookup_widget(GTK_WIDGET(window10),"label166");
	 gtk_label_set_text(GTK_LABEL(label166),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_infirmier,"rb") ;
    t=fopen(tmp_infirmier,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(infirmier),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
           if( ID==M.ID)
            {
		M.cin=CIN;
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_infirmier,"wb") ;
     t=fopen(tmp_infirmier,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(infirmier),1,t)!=0)
     {fwrite(&M,sizeof(infirmier),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_infirmier,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label166;
	label166= lookup_widget(GTK_WIDGET(window10),"label166");
	 gtk_label_set_text(GTK_LABEL(label166),temp);
}
}


void on_button77_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
int ex;
	long int ID,age;
	infirmier M;
	char fichier_infirmier[]="infirmier.txt";
 	char tmp_infirmier[]="tmp_infirmier.txt";        
        GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
	GtkWidget *entry124;

	entry124= lookup_widget(objet_graphique,"entry124");
	ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry124)));
	GtkWidget *entry175;
	entry175= lookup_widget(objet_graphique,"entry175");
	ex=existence_infirmier_ID(fichier_infirmier,M,ID);
        age=atoi ( gtk_entry_get_text(GTK_ENTRY(entry175)));
	if(ex==1)
	{
	
	char temp[]="age modifier ";
	GtkWidget *label167;
	label167= lookup_widget(GTK_WIDGET(window10),"label167");
	 gtk_label_set_text(GTK_LABEL(label167),temp);
	



    FILE *f ;
    FILE *t ;
    f=fopen(fichier_infirmier,"rb") ;
    t=fopen(tmp_infirmier,"wb") ;
    if (f!= NULL && t!=NULL)
     {
      while(fread(&M,sizeof(infirmier),1,f)!=0)
       {
          if( ID!=M.ID)
            {
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
           if( ID==M.ID)
            {
		M.age=age;
             fwrite(&M,sizeof(infirmier),1,t) ;
            }
       }
     }

     fclose(f) ;
     fclose(t) ;
     f=fopen(fichier_infirmier,"wb") ;
     t=fopen(tmp_infirmier,"rb") ;
     if(f!=NULL && t!=NULL)
{
     while(fread (&M,sizeof(infirmier),1,t)!=0)
     {fwrite(&M,sizeof(infirmier),1,f) ;}
}
     fclose(f) ;
     fclose(t) ;     
     t=fopen(tmp_infirmier,"wb+") ;
     if (t!=NULL)	
     {
     }
}
else
{
		char temp[]="erreur ID ";
	GtkWidget *label167;
	label167= lookup_widget(GTK_WIDGET(window10),"label167");
	 gtk_label_set_text(GTK_LABEL(label167),temp);
}
}


void on_button79_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button78_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button80_clicked(GtkWidget *objet_graphique,gpointer user_data)
{

}


void on_button69_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
Patient M;
	char chemin[]="patient.txt";
	char temp[10000]="erreur de saisie patient:\n";
	char ma[10]="masculin";
	char fe[10]="feminin";
	int n=0;
	GtkWidget *entry110;
	GtkWidget *entry111;
	GtkWidget *entry112;
	GtkWidget *entry113;
	GtkWidget *entry114;
	GtkWidget *entry115;
	GtkWidget *entry116;
	GtkWidget *entry117;
	GtkWidget *entry118;
	GtkWidget *entry119;
	GtkWidget *entry120;
	GtkWidget *entry121;
	GtkWidget *entry122;

	entry110= lookup_widget(objet_graphique,"entry110");
	entry111= lookup_widget(objet_graphique,"entry111");
	entry112= lookup_widget(objet_graphique,"entry112");
	entry113= lookup_widget(objet_graphique,"entry113");
	entry114= lookup_widget(objet_graphique,"entry114");
	entry115= lookup_widget(objet_graphique,"entry115");
	entry116= lookup_widget(objet_graphique,"entry116");
	entry117= lookup_widget(objet_graphique,"entry117");
	entry118= lookup_widget(objet_graphique,"entry118");
	entry119= lookup_widget(objet_graphique,"entry119");
	entry120= lookup_widget(objet_graphique,"entry120");
	entry121= lookup_widget(objet_graphique,"entry121");
	entry122= lookup_widget(objet_graphique,"entry122");

	strcpy(M.nom,gtk_entry_get_text(GTK_ENTRY(entry110)));
	strcpy(M.prenom,gtk_entry_get_text(GTK_ENTRY(entry111)));
	strcpy(M.sexe,gtk_entry_get_text(GTK_ENTRY(entry112)));
	strcpy(M.role,gtk_entry_get_text(GTK_ENTRY(entry113)));
	M.cin= atoi( gtk_entry_get_text(GTK_ENTRY(entry114)));
	M.age= atoi( gtk_entry_get_text(GTK_ENTRY(entry115)));
	M.ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry116)));
	M.date_embauche.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry117)));
	M.date_embauche.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry118)));
	M.date_embauche.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry119)));
	M.date_naissance.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry120)));
	M.date_naissance.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry121)));
	M.date_naissance.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry122)));
if( ((strlen(M.nom))<3) || ((strlen(M.prenom))<3) || (((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0)) ||
((M.date_embauche.jour)>31) || ((M.date_embauche.jour)<1) || ((M.date_naissance.jour)>31) || ((M.date_naissance.jour)<1) ||
((M.date_embauche.mois)>12) || ((M.date_embauche.mois)<1) || ((M.date_naissance.mois)>12) || ((M.date_naissance.mois)<1) ||
((M.date_embauche.annee)>2014)||(M.date_naissance.annee)>(M.date_embauche.annee+20))
{
		if (((strlen(M.nom))<3))
		{
	 strcat(temp,"erreur nom \n");
		}
if (((strlen(M.prenom))<3))
		{
	 strcat(temp,"erreur prenom \n");
		}
if (((strcmp(ma,M.sexe))!=0)&&((strcmp(fe,M.sexe))!=0))
		{
	 strcat(temp,"erreur sex : masculin/feminin \n");
		}
if (((M.date_embauche.jour)>31) || ((M.date_embauche.jour)<1))
		{
	 strcat(temp,"erreur jour d'entrée  \n");
		}
if (((M.date_naissance.jour)>31) || ((M.date_naissance.jour)<1) )
		{
	 strcat(temp,"erreur jour de naissance \n");
		}
if (((M.date_embauche.mois)>12) || ((M.date_embauche.mois)<1))
		{
	 strcat(temp,"erreur mois d'entrée \n");
		}
if (((M.date_naissance.mois)>12) || ((M.date_naissance.mois)<1))
		{
 strcat(temp,"erreur mois d'naissance \n");
		}
if ((M.date_embauche.annee)>2014)
		{
	 strcat(temp,"erreur annee d'entrée \n");
		}
if ((M.date_naissance.annee)>(M.date_embauche.annee+20))
		{
	 strcat(temp,"erreur annee d'naissance \n");
		}
		GtkWidget *window8;//declaration
                GtkWidget *window32;
                window8 = lookup_widget(objet_graphique,"window8");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window8);//fermer
                window32 = create_window32();//cree
		gtk_widget_show(window32);//afficher
                GtkWidget *label126;
		label126= lookup_widget(GTK_WIDGET(window32),"label126");
		gtk_label_set_text(GTK_LABEL(label126),temp);
}
else{
	enregistrer_patient(chemin,&M,&n);
	GtkWidget *window7;//declaration
                GtkWidget *window4;
                window7 = lookup_widget(objet_graphique,"window7");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window7);//fermer
                window4 = create_window4();//cree
		gtk_widget_show(window4);//afficher
}
}

// nouvel infirmier
void on_button68_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
	infirmier i;
	char chemin[]="infirmier.txt";
	char temp[10000]="erreur de saisie infirmier:\n";
	char ma[10]="masculin";
	char fe[10]="feminin";
	int n=0;
	GtkWidget *entry97;
	GtkWidget *entry98;
	GtkWidget *entry99;
	GtkWidget *entry100;
	GtkWidget *entry101;
	GtkWidget *entry102;
	GtkWidget *entry103;
	GtkWidget *entry104;
	GtkWidget *entry105;
	GtkWidget *entry106;
	GtkWidget *entry107;
	GtkWidget *entry108;
	GtkWidget *entry109;

	entry97= lookup_widget(objet_graphique,"entry97");
	entry98= lookup_widget(objet_graphique,"entry98");
	entry99= lookup_widget(objet_graphique,"entry99");
	entry100= lookup_widget(objet_graphique,"entry100");
	entry101= lookup_widget(objet_graphique,"entry101");
	entry102= lookup_widget(objet_graphique,"entry102");
	entry103= lookup_widget(objet_graphique,"entry103");
	entry104= lookup_widget(objet_graphique,"entry104");
	entry105= lookup_widget(objet_graphique,"entry105");
	entry106= lookup_widget(objet_graphique,"entry106");
	entry107= lookup_widget(objet_graphique,"entry107");
	entry108= lookup_widget(objet_graphique,"entry108");
	entry109= lookup_widget(objet_graphique,"entry109");

	strcpy(i.nom,gtk_entry_get_text(GTK_ENTRY(entry97)));
	strcpy(i.prenom,gtk_entry_get_text(GTK_ENTRY(entry98)));
	strcpy(i.sexe,gtk_entry_get_text(GTK_ENTRY(entry99)));
	strcpy(i.role,gtk_entry_get_text(GTK_ENTRY(entry100)));
	i.cin= atoi( gtk_entry_get_text(GTK_ENTRY(entry101)));
	i.age= atoi( gtk_entry_get_text(GTK_ENTRY(entry102)));
	i.ID= atoi ( gtk_entry_get_text(GTK_ENTRY(entry103)));
	i.date_embauche.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry104)));
	i.date_embauche.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry105)));
	i.date_embauche.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry106)));
	i.date_naissance.jour=atoi( gtk_entry_get_text(GTK_ENTRY(entry107)));
	i.date_naissance.mois=atoi( gtk_entry_get_text(GTK_ENTRY(entry108)));
	i.date_naissance.annee=atoi( gtk_entry_get_text(GTK_ENTRY(entry109)));
if( ((strlen(i.nom))<3) || ((strlen(i.prenom))<3) || (((strcmp(ma,i.sexe))!=0)&&((strcmp(fe,i.sexe))!=0)) ||
((i.date_embauche.jour)>31) || ((i.date_embauche.jour)<1) || ((i.date_naissance.jour)>31) || ((i.date_naissance.jour)<1) ||
((i.date_embauche.mois)>12) || ((i.date_embauche.mois)<1) || ((i.date_naissance.mois)>12) || ((i.date_naissance.mois)<1) ||
((i.date_embauche.annee)>2014)||(i.date_naissance.annee)>(i.date_embauche.annee+20))
{
		if (((strlen(i.nom))<3))
		{
	 strcat(temp,"erreur nom \n");
		}
if (((strlen(i.prenom))<3))
		{
	 strcat(temp,"erreur prenom \n");
		}
if (((strcmp(ma,i.sexe))!=0)&&((strcmp(fe,i.sexe))!=0))
		{
	 strcat(temp,"erreur sex : masculin/feminin \n");
		}
if (((i.date_embauche.jour)>31) || ((i.date_embauche.jour)<1))
		{
	 strcat(temp,"erreur jour d'embeauche \n");
		}
if (((i.date_naissance.jour)>31) || ((i.date_naissance.jour)<1) )
		{
	 strcat(temp,"erreur jour de naissance \n");
		}
if (((i.date_embauche.mois)>12) || ((i.date_embauche.mois)<1))
		{
	 strcat(temp,"erreur mois d'embeauche \n");
		}
if (((i.date_naissance.mois)>12) || ((i.date_naissance.mois)<1))
		{
 strcat(temp,"erreur mois d'naissance \n");
		}
if ((i.date_embauche.annee)>2014)
		{
	 strcat(temp,"erreur annee d'embeauche \n");
		}
if ((i.date_naissance.annee)>(i.date_embauche.annee+20))
		{
	 strcat(temp,"erreur annee d'naissance \n");
		}
		GtkWidget *window7;//declaration
                GtkWidget *window31;
                window7 = lookup_widget(objet_graphique,"window7");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window7);//fermer
                window31 = create_window31();//cree
		gtk_widget_show(window31);//afficher
                GtkWidget *label125;
		label125= lookup_widget(GTK_WIDGET(window31),"label125");
		gtk_label_set_text(GTK_LABEL(label125),temp);
}
else{
	enregistrer_infirmier(chemin,&i,&n);
	GtkWidget *window7;//declaration
                GtkWidget *window5;
                window7 = lookup_widget(objet_graphique,"window7");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window7);//fermer
                window5 = create_window5();//cree
		gtk_widget_show(window5);//afficher
}
}


void on_button130_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window6;//declaration
                GtkWidget *window30;
                window30 = lookup_widget(objet_graphique,"window30");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window30);//fermer
                window6 = create_window6();//cree
		gtk_widget_show(window6);//afficher
}


void on_button131_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window7;//declaration
                GtkWidget *window31;
                window31 = lookup_widget(objet_graphique,"window31");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window31);//fermer
                window7 = create_window7();//cree
		gtk_widget_show(window7);//afficher
}


void on_button132_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
		GtkWidget *window8;//declaration
                GtkWidget *window32;
                window32 = lookup_widget(objet_graphique,"window32");//chercher ou est la fenetre ou le label
                gtk_widget_hide(window32);//fermer
                window8 = create_window8();//cree
		gtk_widget_show(window8);//afficher
}

